package com.lagou.service.demo;

import com.lagou.service.HelloService;

import java.util.ServiceLoader;


public class ServiceLoaderMain {
    public static void main(String[] args) {
        //从所有项目META-INF/services 中以接口全限定名命名的文件中找所有的实现类
        //并实例化获取到对象
        ServiceLoader<HelloService> helloServices = ServiceLoader.load(HelloService.class);
        for (HelloService helloService : helloServices) {
            System.out.println(helloService.getClass().getName() + ": " + helloService.sayHello());
        }
    }
}
